﻿
using LS.Nc6.Core.Util;

namespace LS.Nc6.Application.Cms
{
    [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
    [ApiDescriptionSettings("CMS")]
    public class DictionaryDataService : IDynamicApiController
    {
        private readonly ISysUserService _userService;

        private readonly IHttpContextAccessor _httpContextAccessor;

        private readonly IEventPublisher _eventPublisher;

        private readonly ISysConfigurationService _configurationService;

        private readonly ISysDictionaryService _sysDictionaryService;
        public DictionaryDataService(ISysUserService userService, IEventPublisher eventPublisher, ISysConfigurationService configurationService, IHttpContextAccessor httpContextAccessor, ISysDictionaryService sysDictionaryService)
        {
            _userService = userService;
            _httpContextAccessor = httpContextAccessor;
            _eventPublisher = eventPublisher;
            _configurationService = configurationService;
            _sysDictionaryService = sysDictionaryService;
        }

        /// <summary>
        /// 获取资讯广告类型
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [Route("api/dicdata/banner")]
        public async Task<List<DictionaryOutput>> GetBannerType()
        {
            var result = await _sysDictionaryService.List(a =>a.ParentId == SqlFunc.Subqueryable<SysDictionaryEntity>().Where(b=>b.Dictype == SysDictionaryType.ENUM_BANNERTYPE.ToString()).Select(b=>b.Id), a => a.Dseq);
            var datalist = result.Adapt<List<DictionaryOutput>>();
            return datalist;
        }
        /// <summary>
        /// 获取链接类型
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [Route("api/dicdata/link")]
        public  async Task<List<DictionaryOutput>> GetLinkType()
        {
           var dic= EnumUtil.EnumToList(typeof(LinkType));
            List<DictionaryOutput>  list   =new List<DictionaryOutput> ();
            foreach (var d in dic) {

                list.Add(new DictionaryOutput { DName = d.Name, DValue = d.Value.ToString(), DSeq = d.Value,Description =d.Describe });
            }
            return  list;
        }

    }
}
